home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / fragrouter / fragrouter.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-21  |  5.0 KB  |  189 lines

  1. /*
  2.   fragrouter.c
  3.  
  4.   network IDS evasion toolkit.
  5.  
  6.   Dug Song <dugsong@anzen.com>
  7.  
  8.   Copyright (c) 1999 Anzen Computing. All rights reserved.
  9.  
  10.   Redistribution and use in source and binary forms, with or without
  11.   modification, are permitted provided that the following conditions
  12.   are met:
  13.   
  14.   1. Redistributions of source code must retain the above copyright
  15.      notice, this list of conditions and the following disclaimer.
  16.   2. Redistributions in binary form must reproduce the above copyright
  17.      notice, this list of conditions and the following disclaimer in the
  18.      documentation and/or other materials provided with the distribution.
  19.   3. All advertising materials mentioning features or use of this software
  20.      must display the following acknowledgement:
  21.      This product includes software developed by Anzen Computing.
  22.   4. Neither the name of Anzen Computing nor the names of its
  23.      contributors may be used to endorse or promote products derived
  24.      from this software without specific prior written permission.
  25.  
  26.   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  27.   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  28.   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  29.   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  30.   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31.   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  32.   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33.   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  34.   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  35.   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  36.   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37.   
  38.   $Id: fragrouter.c,v 1.23 1999/09/21 15:47:32 dugsong Exp $
  39. */
  40.  
  41. #include "config.h"
  42.  
  43. #ifdef STDC_HEADERS
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #include <string.h>
  47. #endif
  48. #ifdef HAVE_UNISTD_H
  49. #include <sys/types.h>
  50. #include <unistd.h>
  51. #endif
  52. #include "ip_frag.h"
  53. #include "sniff.h"
  54. #include "send.h"
  55. #include "attack.h"
  56. #include "version.h"
  57.  
  58. void
  59. usage(void)
  60. {
  61.   int i;
  62.   char *str;
  63.   
  64.   fprintf(stderr, "Version " FRAGROUTER_VERSION "\n"
  65.       "Usage: fragrouter [-i interface] [-p] [-g hop] [-G hopcount] ATTACK\n\n"
  66.       " where ATTACK is one of the following:\n\n");
  67.  
  68.   for (i = 1; i < 10; i++)
  69.     if ((str = attack_string(ATTACK_BASE, i)) != NULL)
  70.       fprintf(stderr, " -B%d: %s\n", i, str);
  71.  
  72.   for (i = 1; i < 10; i++)
  73.     if ((str = attack_string(ATTACK_FRAG, i)) != NULL)
  74.       fprintf(stderr, " -F%d: %s\n", i, str);
  75.   
  76.   for (i = 1; i < 10; i++)
  77.     if ((str = attack_string(ATTACK_TCP, i)) != NULL)
  78.       fprintf(stderr, " -T%d: %s\n", i, str);
  79.   
  80.   for (i = 1; i < 10; i++)
  81.     if ((str = attack_string(ATTACK_TCBC, i)) != NULL)
  82.       fprintf(stderr, " -C%d: %s\n", i, str);
  83.   
  84.   for (i = 1; i < 10; i++)
  85.     if ((str = attack_string(ATTACK_TCBT, i)) != NULL)
  86.       fprintf(stderr, " -R%d: %s\n", i, str);
  87.  
  88.   for (i = 1; i < 10; i++)
  89.     if ((str = attack_string(ATTACK_INSERT, i)) != NULL)
  90.       fprintf(stderr, " -I%d: %s\n", i, str);
  91.  
  92.   for (i = 1; i < 10; i++)
  93.     if ((str = attack_string(ATTACK_EVADE, i)) != NULL)
  94.       fprintf(stderr, " -E%d: %s\n", i, str);
  95.  
  96.   for (i = 1; i < 10; i++)
  97.     if ((str = attack_string(ATTACK_MISC, i)) != NULL)
  98.       fprintf(stderr, " -M%d: %s\n", i, str);
  99.   
  100.   fprintf(stderr, "\n");
  101.   exit(1);
  102. }
  103.  
  104. int
  105. main(int argc, char *argv[])
  106. {
  107.   char c, ebuf[BUFSIZ], hops[BUFSIZ], *dev = NULL;
  108.   int num = 0, type = -1, hopptr = 4;
  109.   attack_handler attack;
  110.  
  111.   hops[0] = '\0';
  112.   
  113.   while ((c = getopt(argc, argv, "B:F:T:C:R:I:E:M:i:g:G:pVh")) != EOF) {
  114.     switch (c) {
  115.     case 'B':
  116.       type = ATTACK_BASE;
  117.       num = atoi(optarg);
  118.       break;
  119.     case 'F':
  120.       type = ATTACK_FRAG;
  121.       num = atoi(optarg);
  122.       break;
  123.     case 'T':
  124.       type = ATTACK_TCP;
  125.       num = atoi(optarg);
  126.       break;
  127.     case 'C':
  128.       type = ATTACK_TCBC;
  129.       num = atoi(optarg);
  130.       break;
  131.     case 'R':
  132.       type = ATTACK_TCBT;
  133.       num = atoi(optarg);
  134.       break;
  135.     case 'I':
  136.       type = ATTACK_INSERT;
  137.       num = atoi(optarg);
  138.       break;
  139.     case 'E':
  140.       type = ATTACK_EVADE;
  141.       num = atoi(optarg);
  142.       break;
  143.     case 'M':
  144.       type = ATTACK_MISC;
  145.       num = atoi(optarg);
  146.       break;
  147.     case 'p':
  148.       ip_frag_init(1);
  149.       break;
  150.     case 'g':
  151.       strcat(hops, optarg);
  152.       strcat(hops, " ");
  153.       break;
  154.     case 'G':
  155.       hopptr = atoi(optarg);
  156.       break;
  157.     case 'i':
  158.       dev = strdup(optarg);
  159.       break;
  160.     default:
  161.       usage();
  162.     }
  163.   }
  164.   argc -= optind;
  165.   argv += optind;
  166.   
  167.   if (argc != 0 || type == -1) usage();
  168.  
  169.   if (!sniff_init(dev, ebuf)) {
  170.     fprintf(stderr, "fragrouter: sniff_init failed: %s\n", ebuf);
  171.     exit(1);
  172.   }
  173.   if (!send_init(ebuf, hops, hopptr)) {
  174.     fprintf(stderr, "fragrouter: send_init failed: %s\n", ebuf);
  175.     exit(1);
  176.   }
  177.   if (!(attack = attack_init(type, num, ebuf))) {
  178.     fprintf(stderr, "fragrouter: attack_init failed: %s\n", ebuf);
  179.     exit(1);
  180.   }
  181.   fprintf(stderr, "fragrouter: %s\n", attack_string(type, num));
  182.   
  183.   sniff_loop(attack);
  184.  
  185.   exit(0);
  186. }
  187.  
  188. /* 5000. */
  189.